﻿var shop = null;
var isupdate = false;
//if (document.location.search != "") document.write("<script type=\"text/javascript\" src='" + "RequestHandler.ashx" + document.location.search + "'><\/script>");
function go(loc) {
    window.location.href = loc + document.location.search;
}
function setTitle(html) {
    $("#p_ProductName").html(html);
}


$(document).ready(function () {
//    var url = "RequestHandler.ashx" + document.location.search;
//    $.get(url, function (data) {
//        var json = (new Function('return ' + data))();
//        initData(json);
//    });

    $("#KeyWords").keyup(function () {
        var productName = $("#ProductName").val();
        var keyword = $("#KeyWords").val();
        var index = productName.indexOf(keyword);
        if (productName != "" && index != -1) {
            var html = "<span>" + productName.replace(keyword, "<span class=H id=\"dd\">" + keyword + "</span>") + "</span>";
            setTitle(html);
        }
    });
    $("#IsCreditCard").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsCreditCard").show();
        else
            $("#p_IsCreditCard").hide();
    });
    $("#IsCashonDelivery").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsCashonDelivery").show();
        else
            $("#p_IsCashonDelivery").hide();
    });
    $("#IsGenuineProtection").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsGenuineProtection").show();
        else
            $("#p_IsGenuineProtection").hide();
    });
    $("#IsLogo").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsLogo").show();
        else
            $("#p_IsLogo").hide();
    });
    $("#IsRetreat").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsRetreat").show();
        else
            $("#p_IsRetreat").hide();
    });
    $("#IsProtection").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsProtection").show();
        else
            $("#p_IsProtection").hide();
    });
    $("#IsPublicbaby").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsPublicbaby").show();
        else
            $("#p_IsPublicbaby").hide();
    });
    $("#IsAllDayShipping").click(function () {
        var flag = $(this).attr("checked");
        if (flag)
            $("#p_IsAllDayShipping").show();
        else
            $("#p_IsAllDayShipping").hide();
    });
    $("#Url").blur(function () {
        $("#p_ProductName").attr("href", $(this).val());
    });
    $("#ProductPicture").change(function () {
        $("#p_ProductPicture").attr("src", $(this).val());
    });
    $("#ProductName").keyup(function () {
        var productName = $("#ProductName").val();
        var keyword = $("#KeyWords").val();
        var index = productName.indexOf(keyword);
        var html = "";
        if (keyword != "") {
            html = "<span>" + productName.replace(keyword, "<span class=H id=\"dd\">" + keyword + "</span>") + "</span>";

        } else {
            html = "<span>" + productName + "</span>";
        }
        setTitle(html);
    });
});